package tetris;

public class ShapeStruct {
	public ShapeStruct(Block block) {
		left = 4;
		top = 0;
		this.data = block.getData();
		this.color = block.getColor();
		this.height = block.getHeight();
		this.width = block.getWidth();
	}

	public int left;
	public int top;
	public boolean[][] data;
	public String color;
	private int width;
	private int height;

	public void changeDirection() {
		if (left + height > 10) {
			return;
		}
		
		boolean[][] temp = new boolean[4][4];

		for (var row = 0; row < height; row++) {
			for (var col = 0; col < width; col++) {
				temp[col][height - 1 - row] = this.data[row][col];
			}
		}
		int tempW = width;
		width = height;
		height = tempW;
		data = temp;
	}

	public void moveDown(int rows) {
		top += rows;
	}

	public void moveDown() {
		top++;
	}

	public void moveLeft() {
		if (left > 0)
			left -= 1;
	}

	public void moveRight() {
		if (left + width < 10)
			left += 1;
	}

	public boolean[][] getData() {
		return data;
	}
	
	public boolean getCell(int row,int col) {
		return data[row][col];
	}
	public int getLeft() {
		return left;
	}

	public int getTop() {
		return top;
	}

	public String getColor() {
		return color;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

}
